home *** CD-ROM | disk | FTP | other *** search
- Path: news.halcyon.com!usenet
- From: normanb@halcyon.com (Norm Bryar)
- Newsgroups: comp.lang.c++
- Subject: Re: Visual C++ 4.0 lacking initializers?
- Date: Thu, 25 Jan 1996 17:32:24 GMT
- Organization: Northwest Nexus Inc.
- Message-ID: <4e8eqc$kue@news.halcyon.com>
- References: <31049C46.A26@oz.is>
- NNTP-Posting-Host: blv-pm11-ip18.halcyon.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- I've never seen this attempted; where'd you learn to do this?
- The initializer list can do function calls, I guess, but I've only
- seen it used to call base-class and member-variable constructors,
- never to call another constructor for the class you're already
- constructing.
-
- If you invoke the default Foo constructor, you want to first invoke
- the Foo::Foo(x) constructor with the value 10, then finish the default
- constructor.
-
- How 'bout making a new, private method that does what you want
- Foo::Foo(x) to do, then have both the default and the (x) constructor
- call this abstraction?
-
- --Norm
-
- Hßlfdan Ingvarsson <halfdan@oz.is> wrote:
-
- >Is it me or is this sort of code not possible with VC++ 4.0?
-
- >// Declarations of class Foo
-
- >// VC++ Complains about the line below with the error
- >// error C2436: '__ctor' : cannot initialize member functions
- >Foo::Foo(void) : Foo::Foo(10) {}
-
- >Foo::Foo(x)
- >{
- > // Some stuff
- >}
-
- >Tell me about it,
-
- >Ciao,
-
- > H.
-
- >--
- >-------------------------------------------------------------------------------Halfdan Ingvarsson, Webmaster/Software Engineer, OZ/Snorrabraut 54/105 Iceland
- >WTel: +3545620362, WFax: +3545610362, HTel: +3545644424, E-Mail: halfdan@oz.is
- >HomePage: http://www.oz.is/~halfdan, ObQuote: Little things make big thing?
-
-
-